Skip to content

fix(batch): remove withFileMutationQueue dependency on host shim#36

Merged
PhucHai123 merged 2 commits into
mainfrom
fix/remove-withFileMutationQueue-host-dep
Jun 30, 2026
Merged

fix(batch): remove withFileMutationQueue dependency on host shim#36
PhucHai123 merged 2 commits into
mainfrom
fix/remove-withFileMutationQueue-host-dep

Conversation

@PhucHai123

@PhucHai123 PhucHai123 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

Case summary: pi-agent-flow install: case summary

When running omp plugin install pi-agent-flow, the OMP PluginManager evaluates the published dist/index.js during post-install extension validation. That evaluation failed with:

Export named 'withFileMutationQueue' not found in module
'.../install/global/node_modules/@oh-my-pi/pi-coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts'

The root cause is that pi-agent-flow imports withFileMutationQueue from @earendil-works/pi-coding-agent, and OMP's legacy-pi compat layer rewrites that specifier onto its bundled shim. The current OMP shim does not re-export withFileMutationQueue, so dynamic evaluation throws before the extension factory is reachable, triggering the install rollback.

Fix

  • Replace the host-provided withFileMutationQueue with a local per-file mutation queue in src/batch/execute.ts. This preserves the original concurrency semantics (mutations targeting the same path are serialized across concurrent calls) while removing the dependency on a symbol the host shim lacks.
  • Drop the now-unused withFileMutationQueue declaration from src/ambient.d.ts.

Tests

Added tests/mutation-queue.test.ts covering the new local helper:

  • a single operation runs immediately
  • concurrent operations on the same path are serialized
  • operations on different paths run concurrently
  • the queue continues after a failed operation

Verification

  • npm run lint
  • npm run check:dist
  • npm run test:trace-ui
  • npm test
  • GitHub Actions CI run 28435153905 passed ✓
  • Confirmed that dist/batch/execute.js no longer imports withFileMutationQueue from @earendil-works/pi-coding-agent. The remaining runtime imports from that module (parseFrontmatter, DynamicBorder, createBashToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, truncateHead, getMarkdownTheme) are still provided by the OMP legacy shim.

Scope

This is the author-fix path from the case summary (option 2). It makes the current release installable against the current OMP build without requiring an upstream OMP re-sync.

Closes the install failure case for pi-agent-flow@2.3.8.

@PhucHai123 PhucHai123 force-pushed the fix/remove-withFileMutationQueue-host-dep branch 2 times, most recently from cf1f8e8 to ebcb870 Compare June 30, 2026 09:37
The OMP legacy-pi-coding-agent-shim does not re-export
withFileMutationQueue, so importing it from
@earendil-works/pi-coding-agent caused extension validation to fail
when omp plugin install pi-agent-flow evaluated dist/index.js.

Replace the host-provided helper with a local per-file mutation queue
in src/batch/execute.ts. This preserves the original serialization
semantics (concurrent mutations on the same path are queued) while
removing the symbol that the host shim is missing.

Also drop the now-unused declaration from src/ambient.d.ts.
Add deterministic tests for the new local mutation queue helper:
- single operation runs immediately
- concurrent operations on the same path are serialized
- operations on different paths run concurrently
- queue continues after a failed operation

Export withFileMutationQueue from execute.ts so the tests can import it
directly.
@PhucHai123 PhucHai123 force-pushed the fix/remove-withFileMutationQueue-host-dep branch from ebcb870 to 8884d66 Compare June 30, 2026 09:42
@PhucHai123 PhucHai123 merged commit e4ed15e into main Jun 30, 2026
1 check passed
@PhucHai123 PhucHai123 deleted the fix/remove-withFileMutationQueue-host-dep branch July 5, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant